﻿@model Volga_It.Hotels.Models.RoomModels
@{
    ViewBag.Title = "Бронирование";
    if (ViewBag.ShowMessage != null && ViewBag.ShowMessage != "")
    { 
        <script>
            alert("@ViewBag.ShowMessage")
        </script>
    }
}

<h2>Информация о комнате</h2>

<div id="details">
    <span class="column">
        @Html.LabelFor(model => model.RoomId)
        @Html.DisplayTextFor(model => model.RoomId)
    </span>
    <span class="column">
        @Html.LabelFor(model => model.RoomNumber)
        @Html.DisplayTextFor(model => model.RoomNumber)
    </span>
    <span class="column">
        @Html.LabelFor(model => model.HotelName)
        @Html.DisplayTextFor(model => model.HotelName)
    </span>
    <span class="column">
        @Html.LabelFor(model => model.RoomType)
        @Html.DisplayTextFor(model => model.RoomType)
    </span>
    <span class="column">
        @Html.LabelFor(model => model.MaxPeople)
        @Html.DisplayTextFor(model => model.MaxPeople)
    </span>
    <span class="column">
        @Html.LabelFor(model => model.Price)
        @Html.DisplayTextFor(model => model.Price)
    </span>
</div>

<div>
    <h3>Описание номера</h3>
    @Html.DisplayTextFor(model => model.Description)
</div>

@{
    List<SelectListItem> items = new List<SelectListItem>();
    foreach (DateTime date in Model.AvailableDates)
    { 
        items.Add(new SelectListItem() { Value = date.ToShortDateString(), Text = date.ToShortDateString() });
    }    
}
<div>
    @if(Model.AvailableDates.Count > 0)
    { 
        <h3>Забронируйте комнату!</h3>
        <p>
            Чтобы забронировать комнату, выберите доступную дату из списка и нажмите на кнопку
        </p>
        using (Html.BeginForm("BookRoom", "Home", FormMethod.Post))
        {
            @Html.AntiForgeryToken();
            @Html.HiddenFor(model => model.RoomId)
            @Html.DropDownListFor(model => model.SelectedDate, items.AsEnumerable())
            <p>
                <input type="submit" value="Забронировать" />
            </p>
        }
    }
</div>
<style>
    .column {
        float: left;
        margin-right: 18px;
    }
    #details{
        height: 50px;
        margin-top: 20px;
    }

</style>